package com.example.demo.Mappers;

import com.example.demo.DynaSQL.NaExamProvider;
import com.example.demo.beans.*;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**核酸检测Mapper
 * Created by 黄启位 on 2022-01-18.
 */
@Mapper
public interface NaExamMapper {
    @Select("select RTRIM(mxfyxmbm)xmbm,rtrim(mxfyxmmc)xmmc ,fydj,a.xlbm,a.hsks,b.dlbm from gyb_mxfyxm a  with(nolock),gyb_fyxl b with(nolock)  where mxfyxmmc like'%病原体核糖核酸扩增定性检测%' and a.qyzt='0'  and a.xlbm=b.xlbm")
    //获取核酸检测项目数据
    List<NaExamItemBean>GetNaExamItem();
    @Select("select top 1 rtrim(ylkh)CardNo,ylklxbm as'CardType',rtrim(a.brid)PatientId,RTRIM(a.brxm)Name,a.brxb as Sex,a.brsr as Birthday,RTRIM(a.sfzh)as'IDCardNo',RTRIM(a.lxrdh)Mobile,RTRIM(jtzz)Address ,brnl as'Age' from v_ghb_zcxx a with(nolock)left join v_ghb_mzylkxx b with(nolock) on a.brid=b.brid where a.brid=#{brid}  ")
    //获取核酸检测人员基础信息
    NaExamPatientInfo GetNaExamPatintInfo(@Param("brid")String brid);

    @Select("select RTRIM(mxfyxmbm)xmbm,rtrim(mxfyxmmc)xmmc ,fydj,a.xlbm,a.hsks,b.dlbm from gyb_mxfyxm a  with(nolock),gyb_fyxl b with(nolock)  where mxfyxmmc like'%病原体核糖核酸扩增定性检测%' and a.qyzt='0'  and a.xlbm=b.xlbm and a.mxfyxmbm=#{mxfyxmbm}")
    //获取具体要核酸检测的项目信息
    NaExamItemBean GetNaExamItemBybm(@Param("mxfyxmbm")String mxfyxmbm);

    @InsertProvider(type = NaExamProvider.class,method = "InsertJysq")
    //插入检验申请表
    void InsertJysq(jysqdBean b);

    @InsertProvider(type =  NaExamProvider.class,method = "InsetJysqmx")
    //插入检验申请明细表
    void  InsertJysqmx(jysqdmxBean b);
    @InsertProvider(type =NaExamProvider.class,method = "InsertMzbbrfy")
    //插入门诊费用表
    void InsertMzfyb(mzbBrfyBean b);

    @InsertProvider(type =NaExamProvider.class,method = "InsertAutoRegist")
    //插入网上交易费用明细表
    void  InsertAutoRegist(PayDetailBean bean);

    @InsertProvider(type =NaExamProvider.class,method = "InsertGhjsjl")
    //插入挂号表结算记录表
    void InsertGhbjsjl(JsjlBean bean);

    @InsertProvider(type =NaExamProvider.class,method = "InsertAutoOrderList")
    //插入网上预约记录表
    void InsertAutoOderlist(AutoOrderBean b);

    @Select("select rtrim(a.brxm)Name,rtrim(a.brid)PatientId,RTRIM(b.ghxh)Mzh, RTRIM(a.sfzh)IdCardNo,c.sqsj,c.sjhj,rtrim(e.mxfyxmbm)xmbm,RTRIM(e.mxfyxmmc)xmmc from v_ghb_zcxx a with(nolock)left join v_ghb_brgh b   with(nolock)on a.brid=b.brid left join mzys_jysq c with(nolock)on b.ghxh=c.ryghxh left join mzys_jysqmx d with(nolock) on c.jysqh=d.jysqh left join gyb_mxfyxm e with(nolock) on d.mxfyxmbm=e.mxfyxmbm where a.brid=#{brid} and e.mxfyxmmc like'%病原体核糖核酸扩增定性检测%'")
    List<NaExamReBean> GetNaExamRes(@Param("brid")String brid);
}
